package com.example.mansystem.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mansystem.dto.ChangeDepartmentDto;
import com.example.mansystem.dto.ChangePlaceDto;
import com.example.mansystem.entity.DepartmentDO;
import com.example.mansystem.entity.PlaceDO;
import com.example.mansystem.mapper.PlaceMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PlaceService  extends ServiceImpl<PlaceMapper, PlaceDO> {
    @Resource
    PlaceMapper placeMapper;

    public void ChangePlace(ChangePlaceDto dto)
    {
        for(int i=0;i<dto.getPlaceCreate().size();i++)
        {
            placeMapper.insert(dto.getPlaceCreate().get(i));
        }
        for(int i=0;i<dto.getPlaceUpdate().size();i++)
        {
            placeMapper.updateById(dto.getPlaceUpdate().get(i));
        }
        for(int i=0;i<dto.getPlaceDelete().size();i++)
        {
            QueryWrapper<PlaceDO> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("placeId",dto.getPlaceDelete().get(i));
            placeMapper.delete(queryWrapper);
        }
    }
}
